import * as type from '../mutation-types'

// initial state
// shape: [{ id, quantity }]

const state = {
    usage:'',
    imgList:[],
    intro:'',
    amount:'',
    days:'',
    serviceFee:'',
    payway:'HBFX',
    yearRate:500,
    isPublic:1,
    isAccredit:0,

}

// mutations
const mutations = {
    [type.REMOVE_LOANINFORM]( state , object ) {
            state.amount = ''
            state.days = ''
            state.serviceFee = ''
            state.payway = 'HBFX'
            state.yearRate = 500
            state.isPublic = 1
            state.isAccredit = 0
            state.usage = ''
            state.imgList = []
            state.intro = ''
    },
    [type.SET_LOANINUSEFORM]( state , object, remove ) {
        if(remove){
            state.usage = ''
            state.imgList = ''
            state.intro = ''
            return
        }
        state.usage = object.usage
        state.imgList = object.imgList
        state.intro = object.intro
    },
    [type.SET_LOANINAPPLYFORM]( state , object, remove ) {
        if(remove){
            state.amount = ''
            state.isAccredit = ''
            state.days = ''
            state.payway = ''
            return
        }
        state.amount = object.amount
        state.isAccredit = object.isAccredit
        state.days = object.days
        state.payway = object.payway
    },
    [type.SET_LOANINPUBLISHFORM]( state , object, remove ) {
        if(remove){
            state.amount = ''
            state.days = ''
            state.serviceFee = ''
            state.payway = ''
            state.yearRate = ''
            state.isPublic = ''
            return
        }
        state.amount = object.amount
        state.days = object.days
        state.payway = object.payway
        state.serviceFee = object.serviceFee
        state.yearRate = object.yearRate
        state.isPublic = object.isPublic
    },

}

export default{ state, mutations }